import http from './http'

function getBaseUrl (resquest) {
  if (resquest.indexOf('http') === -1) {
    if (process.env.NODE_ENV === 'development') {
      return '/api' + resquest
    } else {
      return resquest
    }
  } else {
    return resquest
  }
}

// get请求
export function getAPI (resquest, params) {
  return http.get(getBaseUrl(resquest), params)
}

// post请求
export function postAPI (resquest, params) {
  return http.post(getBaseUrl(resquest), params)
}